package com.tong.lib.mvp;

import android.os.Bundle;
import androidx.annotation.Nullable;

import com.tong.lib.base.BaseActivity;
import com.tong.lib.utils.TUtil;

public abstract class BaseMvpActivity<P extends BasePresenter> extends BaseActivity implements IBaseView {

    private P mPresenter;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mPresenter = TUtil.getT(this,0);
        mPresenter.attachView(this);
        init(savedInstanceState);
        initEvent();
    }

    protected P getP() {
        return mPresenter;
    }

    @Override
    protected void onDestroy() {
        if (mPresenter != null) {
            mPresenter.detachView();
        }
        super.onDestroy();
    }

    @Override
    public void showLoading() {
        super.showLoading();
    }

    @Override
    protected boolean isMvp() {
        return true;
    }
}
